import requests


class Ihrm_Emp_Api:

    @classmethod
    def add_emp(cls,header,data):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user", headers=header, json=data)
        return resp

    @classmethod
    def query_emp(cls,emp_id,header):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id, headers=header)
        return resp

    @classmethod
    def edit_emp(cls, emp_id, header,json_data):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id, headers=header,json=json_data)
        return resp

    @classmethod
    def del_emp(cls, emp_id, header):
        resp = requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id, headers=header)
        return resp


if __name__ == '__main__':
    emp_id = "1730427487172714496"
    header = {"Authorization": "e39eb10a-a08d-4d63-a7d9-96354364d1f3"}
    add_data = {"username": "员外外1", "mobile": "15739018913", "workNumber": "9527"}
    edit_data={"username": "金员外"}
    # resp=Ihrm_Emp_Api.add_emp(header,add_data)
    # print("添加员工：",resp.json())
    # resp = Ihrm_Emp_Api.query_emp(emp_id,header)
    # print("查询员工：", resp.json())
    # resp=Ihrm_Emp_Api.edit_emp(emp_id,header,edit_data)
    # print("修改员工：", resp.json())
    resp=Ihrm_Emp_Api.del_emp(emp_id,header)
    print("删除员工：", resp.json())
